<?php
namespace app\admin\controller;
use app\admin\model\Cate as CateModel;
class RbacRule extends Common
{
    public function lit()
    { 
    	$RuleRes = db('rbac_rule') -> select();
    	$this -> assign('RuleRes',$RuleRes);	
        return $this -> fetch();
    }
    public function add(){
    	if(request()->isPost()){
    		if(db('rbac_rule') -> insert(input('post.'))){
    			$this -> success('添加权限成功','lit');
    		}else{
    			$this -> error('添加权限失败');
    		}
    	}
    	return $this -> fetch();
    }
    public function edit(){
    	if(request()->isPost()){
            if(db('rbac_rule') -> update(input('post.')) !== false){
                $this -> success('编辑权限成功','lit');
            }else{
                $this -> error('编辑权限失败');
            }
        }
    	$id = input('id');
    	$ruleIdRes = db('rbac_rule') -> find($id);
    	$this -> assign('ruleIdRes',$ruleIdRes);
    	return $this -> fetch();
    }
    public function del(){
    	$b = db('rbac_rule') -> delete(input('id'));
    	if($b){
    		$this -> success('删除栏目成功','lit');
    	}else{
    		$this -> error('删除栏目失败');
    	}
    }
}
